package com.wondersgroup.fjzlpt.org.controller.rest.xymb;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.util.QuickPrincipalUtils;
import com.wondersgroup.fjzlpt.org.service.inter.xymb.XymbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 协议管理
 * Created by lion on 2017/6/30.
 */
@RestController
@RequestMapping("/xymb")
public class XymbRestController {

    @Autowired
    private XymbService xymbService;

    /**
     * 分页查询协议模板
     * @param request
     * @return
     */
    @RequestMapping("/queryPageXymb")
    public JSONObject queryPageXymb(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return xymbService.queryPageXymb(map);
    }

    /**
     * 保存协议模板
     * @param request
     * @return
     */
    @RequestMapping("/save")
    public JSONObject save(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        String value = QuickPrincipalUtils.getPtjgID(request);
        map.put("PTJGID", value);
        value = QuickPrincipalUtils.getUserID(request);
        map.put("USERID", value);
        return xymbService.save(map);
    }

    /**
     * 获取协议模板
     * @param request
     * @return
     */
    @RequestMapping("/queryXymb")
    public JSONObject queryXymb(HttpServletRequest request){
        /*协议模板ID*/
        String XYMBID = request.getParameter("XYMBID");
        return xymbService.queryXymb(XYMBID);
    }

    /**
     * 查询服务信息列表
     * @param request
     * @return
     */
    @RequestMapping("/queryPageSummaryFwxx")
    public JSONObject queryPageSummaryFwxx(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        String value = QuickPrincipalUtils.getPtjgID(request);
        map.put("PTJGID", value);
        value = QuickPrincipalUtils.getXzqhdm(request);
        map.put("XZQHDM", value);
        return xymbService.queryPageSummaryFwxx(map);
    }
    
    /**
     * 查询服务信息列表
     * @param request
     * @return
     */
    @RequestMapping("/saveXyAndResutXyid")
    public JSONObject saveXyAndResutXyid(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return xymbService.saveXyAndResutXyid(map);
    }
}




















